/*
 * @lc app=leetcode.cn id=609 lang=golang
 *
 * [609] 在系统中查找重复文件
 */
package Solutions

import (
	"fmt"
	"path"
	"strings"
)

// @lc code=start
func findDuplicate(paths []string) [][]string {
	var contentMap = make(map[string][]string, len(paths))
	for _, v := range paths {
		sp := strings.Split(v, " ")
		pathBase := sp[0]
		fmt.Println(pathBase)
		for _, file := range sp[1:] {
			index := strings.Index(file, "(")
			fileName := file[:index]
			content := file[index+1 : len(file)-1]
			fmt.Println(fileName, content)
			contentMap[content] = append(contentMap[content], path.Join(pathBase, fileName))
		}
	}
	ans := make([][]string, 0, len(contentMap))
	for _, v := range contentMap {
		if len(v) < 2 {
			continue
		}
		ans = append(ans, v)
	}
	return ans
}

// @lc code=end
